"""
    需求：实现新增课程接口的正向测试用例：新增课程成功(仅必填)
"""
import requests

# 发送生成验证码接口请求，获取uuid
resp_verify = requests.get(url="http://kdtx-test.itheima.net/api/captchaImage")
uuid = resp_verify.json().get("uuid")
# 发送登录接口请求，获取token
header_dict_login = {"Content-Type": "application/json"}
json_dict_login = {"username": "admin", "password": "HM_2023_test", "code": "2", "uuid": uuid}
url_str_login = "http://kdtx-test.itheima.net/api/login"
resp_login = requests.post(url=url_str_login, headers=header_dict_login, json=json_dict_login)
token = resp_login.json().get("token")
print("提取token:{}".format(token))
# 发送新增课程接口请求，获取响应数据
url_str_add_course = "http://kdtx-test.itheima.net/api/clues/course"
header_dict_add_course = {"Authorization": "Bearer" + " " + token}
json_dict_add_course = {"name": "小张的课程", "subject": 6, "price": 200, "applicablePerson": 2}
resp_add_course = requests.post(url=url_str_add_course, headers=header_dict_add_course, json=json_dict_add_course)
# 查看响应数据
print(resp_add_course.status_code)
print(resp_add_course.json())
